<template>
	<view class="lookInfo">
		<!-- 材料归还 --- 查看记录 --- 详情 页面 -->
		<navBar title="查看详情" goBackUrl="/subpackage-materials/pages/materials/materialsGoBack/materialsGoBack" @goBack="goBack"></navBar>		
		<scroll-view scroll-y="true" class="scroll-box">
			<view class="content">
				<view class="project">
					<image class="image" src="/subpackage-materials/static/project1.png" mode=""></image>
					<view class="name">
						<view class="t1">{{info.projectName}}</view>
						<view class="t2">{{info.subProjectName}}</view>
					</view>
				</view>
				
				<view class="box uniCollapse">
					<view class="nav border">
						<view class="name">归还编号</view>
						<view class="value">{{info.code}}</view>
					</view>
					<view class="nav border">
						<view class="name">关联出库编号</view>
						<view class="value">{{info.exCode}}</view>
					</view>
					
					<view class="nav border">
						<view class="name">材料归还单</view>
						<view class="value width"></view>
					</view>
					<uni-collapse>
					    <uni-collapse-item v-for="(item,index) in tableData" title-border="show" :key="index" :title="item.name" :value="item.num">
							<template v-slot:title>
								<view class="collapse-title">
									<view class="left">
										{{ item.name }}
									</view>
									<view class="right">
										{{ item.num || ''}}
									</view>
								</view>
							</template>
							<view class="center" v-for="(i,j) in item.list" :key='j'>
								<view class="item">
									<view class="name">规格型号：</view>
									<view class="value">{{i.specificationModel}}</view>
								</view>
								<view class="item">
									<view class="name">过保日期：</view>
									<view class="value">{{i.time}}</view>
								</view>
								<view class="item">
									<view class="name">供应商：</view>
									<view class="value">{{i.supplier}}</view>
								</view>
								<view class="item">
									<view class="name">出库数量：</view>
									<view class="value">{{i.exNum || ''}}{{i.unit || ''}}</view>
								</view>
								<view class="item">
									<view class="name">归还数量：</view>
									<view class="value">{{i.returnNum || ''}}{{i.unit || ''}}</view>
								</view>
							</view>
					    </uni-collapse-item>
					  </uni-collapse>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import { materialReturnWarehouseGetDetailByReturnWarehouseCode } from "@/api/materials/materials.js"
	import { mapMutations, mapState } from "vuex"
 	import mixins from "@/utils/mixins.js"
	import uniCollapse from "./../../../components/uni-collapse/components/uni-collapse/uni-collapse.vue";
	export default {
		name: "lookInfo",
 		mixins: [mixins],
		components: {
			uniCollapse
		},
		data() {
			return {
				list: [
				],
				info:{},
				tableData:[],
				
			}
		},
		computed: {
			...mapState('materials',['goBackDetailItem'])
		},
		mounted() {
			this.info=this.goBackDetailItem
			console.log('info',this.info)
			this.init()
		},
		methods: {
			init(){
				this.getList()
			},
			getList(){
				let _query={
					code:this.info.code
				}
				materialReturnWarehouseGetDetailByReturnWarehouseCode(_query).then(res=>{
					if(res.success){
						console.log('res',res)
						let list=res.result
						if(list.length>0){
							this.info.exCode=list[0].exCode
						}
						//获取所有的类型
						let typeList=Array.from(new Set(list.map(item=>item.subDeviceTypeName)))
						typeList.forEach(item=>{
							let itemObj={
								name:item,
								list:[],
							}
							list.forEach(i=>{
								if(item===i.subDeviceTypeName){
									if(i.expirationDate){
										i.time=this.getDate2(i.expirationDate)
									}
									itemObj.list.push(i)
								}
							})
							this.tableData.push(itemObj)
						})
					}
				})
			},
			goBack(url){
				uni.navigateBack({
					url:url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.lookInfo{
		font-family: PingFang SC-Bold, PingFang SC;
		/* #ifdef MP-WEIXIN */
			padding-top: 180rpx;
		/* #endif */
		.scroll-box{
			max-height: calc(100vh - 170rpx);
			padding-top: 10rpx;
		}
		.content{
			background: #FFFFFF;
			height: calc(100vh - 170rpx);
			.project{
				background-color: #FFFFFF;
				padding: 0rpx 30rpx;
				height: 150rpx;
				display: flex;
				align-items: center;
				padding-top: 40rpx;
				box-sizing: border-box;
				.image{
					width: 70rpx;
					height: 70rpx;
					margin-left: 29rpx;
					margin-right: 40rpx;
				}
				.name{
					.t1{
						font-size: 32rpx;
						font-weight: bold;
						color: #445469;
					}
					.t2{
						font-size: 28rpx;
						font-weight: 500;
						color: #6A819E;
						margin-top: 5rpx;
					}
				}
			}
			
			.box{
				padding: 0rpx 30rpx;
				background-color: #FFFFFF;
			}
			.nav{
				line-height: 100rpx;
				height: 100rpx;
				padding: 0rpx 28rpx;
				display: flex;
				justify-content: space-between;
				
				.name{
					font-size: 32rpx;
					font-weight: bold;
					color: #445469;
				}
				.value{
					font-size: 32rpx;
					font-weight: bold;
					color: #445469;
				}
				.width{
					width: 120rpx;
					text-align: center;
				}
			}
			.border{
				border-bottom: 1rpx solid #d6d7d9;
			}
			
			.center{
				background-color: #FBFDFF;
				padding: 32rpx 38rpx;
				padding-top: 12rpx;
				border-bottom: 2rpx solid #E2E5ED;
				.item{
					display: flex;
					align-items: center;
					margin-top: 20rpx;
					
					.name{
						width: 150rpx;
					}
					.right{
						width: 300rpx;
						text-align: right;
					}
				}
				.m40{
					justify-content: space-between;
					margin-top: 20rpx;
				}
			}
		}
		
		.flow{
			margin-top: 30rpx;
			background-color: #FFFFFF;
			padding-left: 62rpx;
			padding-right: 72rpx;
			padding-top: 36rpx;
			.f-title{
				font-size: 30rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #22204E;
				margin-bottom: 54rpx;
			}
			.f-body{
				height: 200rpx;
				padding-left: 10rpx;
				display: flex;
				.user{
					flex: 1;
					.user-item{
						text-align: right;
						margin-bottom: 150rpx;
					}
					.userImg{
						width: 50rpx;
						height: 50rpx;
						vertical-align: middle;
						margin-right: 14rpx;
					}
					.username{
						font-size: 22rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 500;
						color: #6A819E;
					}
						
				}
			}
		}
	}
</style>
